<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../res/css/weui.css" />
    <link rel="stylesheet" href="../res/css/weuix.css" />
    <link rel="stylesheet" href="../res//css/common.css">
    <link rel="stylesheet" href="../res/css/swiper.css">
    <script src="../res/js/zepto.min.js"></script>
    <script src="../res/js/zepto.weui.js"></script>
    <script src="../res/js/common.js?v=1"></script>
    <script src="../res/js/swiper.js"></script>
</head>
<style>
    .fix-top {
        border-bottom: 1px solid #e8e8e8;
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        z-index: 1;
        background: #F6F6F9
    }

    body {
        background-color: #fff;
    }

    .listWrappar {
        background: #FBFBFB;
        border-radius: 10px;
        width: 100%;
        overflow: hidden;
        margin: 20px 0;
    }

    .listWrappar>div {
        width: 90%;
        padding: 15px 5%;
        margin: 10px 0;
    }

    .listTitle>p:nth-child(1) {
        font-size: 18px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #2C2C2C;
    }

    .listTitle>p:nth-child(2) {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #353535;
        line-height: 28px;
        margin-left: auto;
    }

    .listTitle>p:nth-child(3) {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #1189FF;
        line-height: 28px;
        margin-left: 5%;
    }

    .drug_list {
        display: flex;
        flex-wrap: wrap;
    }

    .drug_list>p {
        margin: 10px 10px;
    }

    .listMessage {
        display: flex;
        flex-wrap: wrap;
        padding: 0px 5% !important;
    }

    .listMessage>p {
        width: 50%;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #1189FF;

    }
</style>
<script>
    $(function () {
        logId = getQst("logId")

        //获取用户处方信息
        function getAllInfoi() {
            var params = {
                "id": logId
            }
            newAjaxPost("/h5/inquiryLog/getAllInfo", params, getAllInfoOk);
        }
        $("#noList").hide()

        function getAllInfoOk(jsonInfo) {
            console.log(jsonInfo);
            data = jsonInfo.data
            var diagnosis = data.diagnosisDescribe //诊断
            patientName = data.patientName //问诊人
            prescriptionList = data.prescriptionList //下达的处方列表
            prescriptionNoList = [] //申请单数组
            mainSuit = data.mainSuit ? data.mainSuit : "" //主诉
            acceptsTime = data.acceptsTime //接诊时间
            var message = ""
            id = data.id //处方ID
            if (prescriptionList.length == 0) {
                $(".show").hide()
                message += `<div class="message_wrappar" style="margin: 50px 5%;margin-bottom:20px;width: 90%;">
                    <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">处方信息</div>`
                if(acceptsTime){
                    message += `<div style="display:flex;color:#2C2C2C"><p style="width:50%"></p><p style="width:60%;text-align: right;">${acceptsTime}</p></div>`
                }
                else{
                    message += `<div style="display:flex;color:#2C2C2C"><p style="width:50%"></p><p style="width:60%;text-align: right;"></p></div>`
                }
                message += `<div style="margin:10px 0;display:flex;color:#2C2C2C" class="userMessage"><p style="width:25%">问诊人：</p><p style="width:65%">${patientName}</p>></div>
                        <div style="margin:10px 0;display:flex;color:#2C2C2C" ><p style="width:25%">主诉:</p><p style="width:75%">${mainSuit}</p></div>
                        <div style="margin:10px 0;display:flex;color:#2C2C2C"><p style="width:24%">诊断：</p><p style="width:76%">${diagnosis}</p>
                </div>`
                message += `
                <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">检查检验单</div>
                <div class="listWrappar">
                    <div style="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:10px 0;padding:10px 5%;">
                        检查检验意见单： &nbsp;&nbsp;&nbsp;&nbsp;(点击下方查看)</div>
                    <div class="listMessage" style="display: flex;justify-content: center;align-items: center;font-size:14px;">
                        <p style="color: #757575;text-align: center;">暂无数据</p>
                    </div>
                    <div style="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:10px 0;padding:10px 5%;">
                        检查检验申请单： &nbsp;&nbsp;&nbsp;&nbsp;(点击下方查看)</div>
                    <div class="listMessage" >`
                //申请单渲染
                prescriptionNoList.forEach((item) => {
                    console.log(item);
                    message +=
                        `<p applicationFormNo=${item.prescriptionNo} id=${item.id} class="showList">${item.prescriptionNo}</p>`
                })
                message += `</div>
                </div>
                <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">健康指导</div>
                <div class="listWrappar">
                    <div style="display: flex;justify-content: center;align-items: center;">
                        <p>暂无数据</p>
                    </div>
                </div>
                <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">住院建议</div>
                <div class="listWrappar">
                    <div style="display: flex;justify-content: center;align-items: center;">
                        <p>暂无数据</p>
                    </div>
                </div>
                </div>`
                $(".fix-top").after(message)
                //跳转到就诊人详情页面
                $(".userMessage").click(function () {
                    console.log(1);
                    goPage('./user_message.htm?logId=' + logId);
                })
            } else {
                message +=
                    `<div class="message_wrappar" style="margin: 50px 5%;margin-bottom:20px;width: 90%;">
                <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">处方信息</div>
                <div style="display:flex;color:#2C2C2C"><p style="width:50%"></p><p style="width:60%;text-align: right;">${acceptsTime}</p></div>
                        <div style="margin:10px 0;display:flex;color:#2C2C2C" class="userMessage"><p style="width:25%">问诊人：</p><p style="width:75%">${patientName}</p>></div>
                        <div style="margin:10px 0;display:flex;color:#2C2C2C"><p style="width:25%">主诉:</p><p style="width:75%">${mainSuit}</p></div>
                        <div style="margin:10px 0;display:flex;color:#2C2C2C"><p style="width:24%">诊断：</p><p style="width:76%">${diagnosis}</p></div>`
                prescriptionList.forEach((item, index) => {
                    prescriptionState = data.prescriptionList[index]
                        .prescriptionState //处方状态 1.通过 2,驳回 3.审核中

                    prescriptionNoList.push({
                        prescriptionNo: item.prescriptionNo,
                        id: item.id
                    })

                    //判断为中药还是西药 1中 2西
                    if (item.prescriptionType == 1) {
                        //判断审核状态
                        if (prescriptionState == 1) {
                            message += `
                                <div class="listWrappar">
                                <div style="display: flex;height:30px;" class="listTitle">
                                <p>处方${index+1}</p>
                                <p style="background: #F2F2F2;border-radius: 5px;line-height:30px;padding:0 10px" class="saveList">保存处方</p>
                                <p style="background: #1189FF;border-radius: 5px;line-height:30px;padding:0 10px;color: #FFFFFF;" class="buyList" prescriptionNo=${item.prescriptionNo} id="${item.id}" inside="${!Number(item.storeId)}">购买处方</p>
                                </div>`
                        } else {
                            message += `
                                <div class="listWrappar">
                                <div style="display: flex;height:30px;" class="listTitle">
                                <p>处方${index+1}</p>
                                <p style="background: #F2F2F2;border-radius: 5px;line-height:30px;padding:0 10px" class="saveList">保存处方</p>
                                <p style="background: #1189FF;opacity: 0.5;border-radius: 5px;line-height:30px;padding:0 10px;color: #FFFFFF;" class="isCheck" prescriptionNo=${item.prescriptionNo} id="${item.id}" inside="${!Number(item.storeId)}">购买处方</p>
                                </div>`
                            message += `
                                <div style="font-size: 14px;font-family: PingFang SC;font-weight: 500;color: #FA6464;padding:0;">
                                <p style="width:100%;text-align:right">请等待药师审核通过后</p>
                                <p style="width:100%;text-align:right">再购买该处方 </p>
                                </div>`
                        }

                        message += `<div style="border-radius: 5px;overflow: hidden;padding:0 5%">       
                    <img src=${item.imgUrl} alt="" style="width:97px;" class="ListImg"></div>
                    <div>
                    <div class="listTitle" style="display: flex;">
                    <p>用药信息</p>
                    <p style="font-size: 14px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;">付数：${item.prescriptionNum}</p>
                    </div>
                    <div class="drug_list">`
                        item.detailsResps.forEach((element) => {
                            if (element.detailsUsage) {
                                message +=
                                    `<p style="font-size: 15px;">${element.drugName}${element.detailsConsumption}${element.detailsConsumptionUnit}[${element.detailsUsage}]</p>`
                            } else {
                                message +=
                                    `<p style="font-size: 15px;">${element.drugName}${element.detailsConsumption}${element.detailsConsumptionUnit}</p>`
                            }

                        })

                        message += `
                    </div>
                    <div style="display: flex;font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin: 10px 0;">
                    【${item.prescriptionTaking}】${item.prescriptionRequirements}</div>
                    </div>
                    </div>`
                    } else {
                        if (prescriptionState == 1) {
                            message += `
                        <div class="listWrappar">
                        <div style="display: flex;height:30px;" class="listTitle">
                        <p>处方${index+1}</p>
                        <p style="background: #F2F2F2;border-radius: 5px;line-height:30px;padding:0 10px" class="saveList">保存处方</p>
                        <p style="background: #1189FF;border-radius: 5px;line-height:30px;padding:0 10px;color: #FFFFFF;" class="buyList" prescriptionNo=${item.prescriptionNo} id="${item.id}" inside="${!Number(item.storeId)}">购买处方</p>
                        </div>`
                        } else {
                            message += `
                        <div class="listWrappar">
                        <div style="display: flex;height:30px;" class="listTitle">
                        <p>处方${index+1}</p>
                        <p style="background: #F2F2F2;border-radius: 5px;line-height:30px;padding:0 10px" class="saveList">保存处方</p>
                        <p style="background: #1189FF;opacity: 0.5;border-radius: 5px;line-height:30px;padding:0 10px;color: #FFFFFF;" class="isCheck" prescriptionNo=${item.prescriptionNo} id="${item.id}" inside="${!Number(item.storeId)}">购买处方</p>
                        </div>`
                            message += `
                        <div style="font-size: 14px;font-family: PingFang SC;font-weight: 500;color: #FA6464;padding:0;">
                        <p style="width:100%;text-align:right">请等待药师审核通过后</p>
                        <p style="width:100%;text-align:right">再购买该处方 </p>
                        </div>`
                        }
                        message += ` <div style = "border-radius: 5px;overflow: hidden;padding:0 5%">
                        <img src=${item.imgUrl} alt="" style="width:97px;" class="ListImg"></div>
                        <div class = "listTitle"style = "display: flex;">
                            <p> 用药信息</p></div> `
                        item.detailsResps.forEach((ele) => {
                            console.log(ele);
                            message += ` <div style ="font-size: 15px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;margin:1px 0;padding-top:3px" >${ele.drugName}</div>
                                 <div style ="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:1px 0;padding-top:3px" >
                                    ${ele.drugSpecifications}, 总量:${ele.detailsNum}${ele.drugSpecifications.split("")[ele.drugSpecifications.split("").length-1]} </div> 
                                    <div style ="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:1px 0;padding-top:3px" >【${ele.detailsUsage}】
                                    ${ele.detailsFrequencyStr},每次${ele.detailsConsumption}${ele.detailsConsumptionUnit}</div> 
                            <div style ="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:1px 0;padding-top:3px" >
                                注意事项：`
                            if (ele.detailsEntrust) {
                                message += ` ${ele.detailsEntrust}</div>`
                            } else {
                                message += `</div>`
                            }
                        })
                        message += `</div>`
                    }
                });


                message += `
            <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">检查检验单</div>
            <div class="listWrappar">
                <div style="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:10px 0;padding:10px 5%;">
                    报告意见单: &nbsp;&nbsp;&nbsp;&nbsp;(点击下方查看)</div>
                <div class="listMessage">`
                if (data.inspectionOpinionList) {
                    data.inspectionOpinionList.forEach((item) => {
                        message +=
                            `<p applicationFormNo=${item.applicationFormNo} id=${item.id} class="showList" resourceType="3">${item.applicationFormNo}</p>`
                    })
                } else {
                    message += `<p>暂无数据</p>`
                }
                message += `</div>
                <div style="font-size: 13px;font-family: PingFang SC;font-weight: 500;color: #2C2C2C;margin:10px 0;padding:10px 5%;">
                    检查检验申请单： &nbsp;&nbsp;&nbsp;&nbsp;(点击下方查看)</div>
                <div class="listMessage" >`
                //申请单渲染
                if (data.formListResult) {
                    data.formListResult.forEach((item) => {
                        message +=
                            `<p applicationFormNo=${item.applicationFormNo} id=${item.id} class="showList" resourceType="5" template=${item.templateValue}>${item.applicationFormNo}</p>`
                    })
                } else {
                    message += `<p>暂无数据</p>`
                }

                message += `</div>
            </div>
            <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">健康指导</div>
            <div class="listWrappar">`
                if (data.inquiryLogHealthGuidanceList) {
                    data.inquiryLogHealthGuidanceList.forEach((item, index) => {
                        message +=
                            `
                        <p applicationFormNo=${item.healthGuidanceNo} id=${item.id} class="showList" style="padding-left:5%;font-size: 14px;font-family: PingFang SC;font-weight: bold;color: #1189FF;" resourceType="2">${item.healthGuidanceNo}</p>`
                    })
                } else {
                    message += `
                    <div style="display: flex;justify-content: center;align-items: center;">
                        <p>暂无数据</p>
                    </div>`
                }

                message += `</div>
                    <div style="font-size: 20px;font-family: PingFang SC;font-weight: bold;color: #2C2C2C;">住院建议</div>
                    <div class="listWrappar">`
                    if (data.hospitalizationDetailResp) {
                        message += `
                            <div class="listMessage showList" id="${logId}" resourceType="1">
                                <p>住院建议书</p>
                            </div>`

                        $("#zhuYuan").click(function () {
                            
                        })
                    } else {
                    message += `
                        <div style="display: flex;justify-content: center;align-items: center;">
                            <p>暂无数据</p>
                        </div>`
                }
                message += `</div></div>`
                $.showLoading();
                $(".show").hide()
                setTimeout(function () {
                    $.hideLoading();
                    $(".fix-top").after(message)
                    $(".show").show()
                    //审核通过点击事件
                    $(".buyList").click(function () {
                        var order_id = $(this).attr("prescriptionNo")
                        var id = $(this).attr('id')
                        var inside = $(this).attr('inside')
                        goPage('./inquiry_go_order.htm?order_id=' + order_id + '&id=' + id + '&inside=' + inside);
                    })
                    //审核中按钮
                    $(".isCheck").click(function () {
                        msgInfo("您的订单正在审核中，请稍后再购买")
                    })
                    //点击保存处方图片
                    $(".saveList").click(function () {
                        var alink = document.createElement("a");
                        alink.href = $(".ListImg")[0].src;
                        alink.download = true
                        alink.click();
                    })
                    //点击放大处方图片
                    $(".ListImg").click(function () {
                        $(".message_wrappar").hide()
                        $(".fix-top").hide()
                        $(".preImage")[0].src = $(this)[0].src
                    })
                    //点击展示对应处方
                    $(".showList").click(function () {
                        id = $(this).attr("id")
                        resourceType = $(this).attr("resourceType")
                        if (resourceType == 5) {
                            var template = $(this).attr("template")
                            var params = {
                                "id": id,
                                "resourceType": resourceType,
                                "type": 2,
                                "template": template
                            }
                        } else {
                            var params = {
                                "id": id,
                                "resourceType": resourceType,
                                "type": 2,
                            }
                        }
                        newAjaxPost("/h5/pdf/getEstablishPdf", params, (json) => {
                            console.log(json);
                            $(".preImage")[0].src = json.data.url
                            console.log($(".preImage").src);
                        })
                        $(".message_wrappar").hide()
                        $(".fix-top").hide()
                    })
                    //点击关闭处方展示
                    $(".closeList").click(function () {
                        $(".message_wrappar").show()
                        $(".fix-top").show()
                    })

                    //跳转到就诊人详情页面
                    $(".userMessage").click(function () {
                        console.log(1);
                        goPage('./user_message.htm?logId=' + logId);
                    })
                }, 1000)

            }
        }
        getAllInfoi()
        $("#btnBack").click(function () {
            goPageNo(-1)
        })
    })
</script>

<body ontouchstart>
    <div class="fix-top" style="z-index: 100;">
        <div class="weui-btn_primary weui-header">
            <div class="weui-header-left"><a id="btnBack" class="icon icon-109"></a></div>
            <h1 class="weui-header-title">清单</h1>
            <div class="weui-header-right;"></div>
        </div>
    </div>
    <div class="listWrappar" id="noList" style="width: 90%;margin: 0 5%;margin-top: 60px;height: 50px;">
        <p style="text-align: center;line-height: 50px;">暂无处方清单信息</p>
    </div>
    <!-- 处方展示页面 -->
    <div style="width: 100%;height: 100%;position: fixed;background:rgba(0,0,0,0.3);z-index:120;" class="show">
        <div class="closeList"
            style="width: 15%;height: 30px;background: #1189FF;box-shadow: 0px 8px 22px 0px rgba(17, 137, 255, 0.2);border-radius: 10px;text-align: center;color: #fff;margin-top: 5%;margin-left: 80%;">
            关闭</div>
        <img src="" alt="" style="width: 90%;height: 80%;margin: 0 5%;margin-top: 5%;" class="preImage">
    </div>
    <div>&nbsp;</div>
</body>

</html>